#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>

int main(int argc, char *argv[])
{
	int s;
	int len;
	char buf[BUFSIZ];
	struct sockaddr_in remote_addr;

	memset(&remote_addr,0,sizeof(remote_addr));
	remote_addr.sin_family=AF_INET;
	remote_addr.sin_addr.s_addr=inet_addr("127.0.0.1");
	remote_addr.sin_port=htons(8000);

	if((s=socket(PF_INET,SOCK_STREAM,0))<0)
	{
		perror("socket");
		return 1;
	}
	if (connect(s,(struct sockaddr *)&remote_addr,sizeof(struct sockaddr))<0)
	{
		perror("connect");
		return 1;
	}
	printf("connected to server\n");
	len=recv(s,buf,BUFSIZ,0);
	buf[len]='\0';

	printf("%s",buf);
	while(1)
	{
		printf("Enter string to send:\n");
		scanf("%s",buf);
		if(!strcmp(buf,"quit"))
		{
			break;
		}
		len=send(s,buf,strlen(buf),0);
		len=recv(s,buf,BUFSIZ,0);
		buf[len]='\0';
		printf("received:%s\n",buf);
	}
	//while(1)
	//{
		//printf("Enter string to send:");
		//scanf("%s",buf);
		//strcpy(buf,"mount -o user=,pass=,iocharset=utf8 -t cifs //192.168.20.38/tools /1239");

		//len=send(s,buf,strlen(buf),0);
		//while((len=recv(s,buf,BUFSIZ,0))>0){
		//len=recv(s,buf,BUFSIZ,0);
		//	buf[len]='\0';
		//	printf("received:%s\n",buf);
		//}
	//}

	close(s);
	return 0;
}
